﻿using Newtonsoft.Json;
using System.Net.Http;
using System.Threading.Tasks;

namespace Sumc.Client.ModernUI.Extensions
{
    public static class HttpResponseMessageExtensions
    {
        public static async Task<T> ReadAsAsync<T>(this HttpContent content)
        {
            var responseString = await content.ReadAsStringAsync();
            var responseAsObject = await JsonConvert.DeserializeObjectAsync<T>(responseString);
            return responseAsObject;
        }
    }
}
